<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function idJudge(str)
{
	if(str.length<=12 && str.length>=6){}
	else{
		var e0=new Error();
		e0.message="用户名长度必须在6-12个字符之间！";
		throw e0;
	}
	if((str[0]>="a" && str[0]<="z") || (str[0]>="A" && str[0]<="Z")){}
	else{
		var e1=new Error();
		e1.message="用户名首字母必须为字母！";
		throw e1;
	}
	return;
}

function passJudge(str1,str2)
{
	if(str1.length<=12 && str1.length>=6){}
	else{
		var e2=new Error();
		e2.message="密码长度必须在6-12个字符之间！";
		throw e2;
	}
	if(str1==str2){}
	else{
		var e3=new Error();
		e3.message="两次输入的密码不同！";
		throw e3;
	}
	return;
}

function chick(checkbox)
{
	var i;
	var sum=0;
	for(i=0; i<checkbox.length;i++){
		if(checkbox[i].checked){
			sum++;
		}
	}
	if(sum<2){
		var e4=new Error();
		e4.message="选择不得少于两项！";
		throw e4;
	}
}

function Bt(){
	try{
		var id=document.getElementById("ueser").value;
		var ps=document.getElementById("pass").value;
		var psCheck=document.getElementById("passcheck").value;
		var checkBox=document.getElementsByName("ck");
		idJudge(id);
		passJudge(ps,psCheck);
		chick(checkBox);
		alert("恭喜，操作成功！")
	}
	catch(e){
		alert(e.message);
	}
}
</script>
</head>

<body>
<form name="" method="post">
	用户名：&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="text" id="ueser" width="150px" /><br />
	密码：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="password" id="pass" width="150px" /><br />
	密码确认：
	<input type="password" id="passcheck" width="150px" /><br />
	<input type="checkbox" name="ck" value="1" />1
	<input type="checkbox" name="ck" value="2" />2
	<input type="checkbox" name="ck" value="3" />3
	<br />
	<input type="button" name="" onclick="Bt()"  value="提交"/>
</form>
</body>
</html>
